<template>
    <div>
        <el-table
                stripe
                :data="commentList"
                style="width: 100%">
            <el-table-column
                    width="120"
                    align="center"
                    label="评论用户"
                    prop="nickName">
            </el-table-column>
            <el-table-column
                    width="120"
                    align="center"
                    label="评论员工"
                    prop="emp">
            </el-table-column>
            <el-table-column
                    width="160"
                    align="center"
                    label="评论订单编号"
                    prop="orderno">
            </el-table-column>
            <el-table-column
                    width="140"
                    align="center"
                    label="评论产品"
                    prop="product">
            </el-table-column>
            <el-table-column
                    width="180"
                    align="center"
                    label="评论时间"
                    prop="commentTime">
            </el-table-column>
            <el-table-column
                    width="80"
                    align="center"
                    label="评论状态"
                    prop="isPass">
                <template slot-scope="scope">
                    <span v-if="scope.row.isPass==1"><el-tag type="success">已通过</el-tag></span>
                    <span v-else><el-tag type="danger">已禁止</el-tag></span>
                </template>
            </el-table-column>
            <el-table-column
                    align="center"
                    label="评论内容"
                    prop="content">
            </el-table-column>
            <el-table-column  fixed="right" label="操作" align="center" width="80">
                <template slot-scope="scope">
                    <el-button
                            size="mini"
                            type="danger"
                            @click="deleteOrder( scope.row)">禁止
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination
                :page-size="7"
                :pager-count="5"
                @current-change="getCommentByPage"
                layout="prev, pager, next"
                :total="totalComment">
        </el-pagination>
    </div>
</template>

<script>
    export default {
        name: "checkReview",
        data() {
            return {
                commentList:[],     //分页获取的评论列表
                totalComment:null,   //分页总条数
            };
        },
        created() {
            this.getCommentByPage(1);
        },
        methods:{
            getCommentByPage(currentPage){
                var that=this;
                this.$ajax.post('/jz/comment/showCommentByPage?currentPage='+currentPage).then(function (resp) {
                    console.log(resp.data);
                    if(resp.data.status==200){
                        that.totalComment=resp.data.totalCount;
                        that.commentList=resp.data.commentList;
                    }
                })
            },

            deleteOrder(row) {
                //console.log( row);
                this.$confirm('此操作将永久禁用该评论, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    var that=this;
                    this.$ajax.post('/jz/comment/banCommentById?id='+row.id).then(function (resp) {
                        //console.log(resp.data);
                        if(resp.data.status==200){
                            that.$message({
                                message: '删除成功，请刷新！',
                                type: 'success'
                            });
                        }
                        if(resp.data.status==204){
                            that.$message.error('删除失败，请重试！');
                        }
                    })
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            }
        }
    }
</script>

<style scoped>

</style>
